Page 1

ui <- dashboardPage(
  dashboardHeader(title = "My Dashboard"),
  dashboardSidebar(
    # Sidebar content
  ),
  dashboardBody(
    # Body content
    fluidRow(
      column(
        width = 7,
        box(
          title = "Small Panel",
          width = NULL,
          status = "info",
          solidHeader = TRUE,
          collapsible = TRUE,
          p("Ali Kilmen."),
          p("200527086"),
          p("uspopage"),
          p("5/6/2023")
        )
      )
    )
  )
)

server <- function(input, output) {
  # Server logic
}

shinyApp(ui, server)
## PhantomJS not found. You can install it with webshot::install_phantomjs(). If it is installed, please make sure the phantomjs executable can be found via the PATH variable.
Shiny applications not supported in static R Markdown documents

Chart 1

boxplot(Thousands ~ AgeGroup, data = dvp,
        theme_dark(),
        col = "lightblue",
        xlab = "Age Group",
        ylab = "Population (Thousands)",
        main = "Population Distribution by Age Group")

Chart 2

dvp.h1 <- hist(dvp$Year)

Page 2

Chart 3

gg <- ggplot(dvp, aes(x = Year, y = Thousands)) +
  geom_point() +
  labs(x = "Year", y = "Population (Thousands)",
       title = "Relationship between Year and Population")

## Converting the plot upper to a Interactive plot 
ggplotly(gg)

Chart 4

plot(Thousands ~ Year, data = dvp,
     xlab = "Year", ylab = "Population (Thousands)",
     main = "Relationship between Year and Population")

Page 3

colnames(uspopage)
## [1] "Year"      "AgeGroup"  "Thousands"
str(uspopage)
## 'data.frame':    824 obs. of  3 variables:
##  $ Year     : int  1900 1900 1900 1900 1900 1900 1900 1900 1901 1901 ...
##  $ AgeGroup : Factor w/ 8 levels "<5","5-14","15-24",..: 1 2 3 4 5 6 7 8 1 2 ...
##  $ Thousands: int  9181 16966 14951 12161 9273 6437 4026 3099 9336 17158 ...
# Total population
total_population <- sum(uspopage$Thousands)

# Minimum and maximum age groups
min_agegroup <- levels(uspopage$AgeGroup)[1]
max_agegroup <- levels(uspopage$AgeGroup)[length(levels(uspopage$AgeGroup))]

# Average population by age group
average_population <- tapply(uspopage$Thousands, uspopage$AgeGroup, mean)

# Age group with the highest population
max_population_agegroup <- names(average_population)[which.max(average_population)]

# Display the summary statistics
cat("Summary of the uspopage dataset:\n")
## Summary of the uspopage dataset:
cat("Total population:", total_population, "\n")
## Total population: 17221523
cat("Minimum age group:", min_agegroup, "\n")
## Minimum age group: <5
cat("Maximum age group:", max_agegroup, "\n")
## Maximum age group: >64
cat("Average population by age group:\n")
## Average population by age group:
print(average_population)
##       <5     5-14    15-24    25-34    35-44    45-54    55-64      >64 
## 14898.34 29066.43 27541.16 25592.10 22637.67 18282.41 13762.10 15419.06
cat("Age group with the highest population:", max_population_agegroup, "\n")
## Age group with the highest population: 5-14

References

ui <- dashboardPage(
  dashboardHeader(title = "My Dashboard"),
  dashboardSidebar(
    # Sidebar content
  ),
  dashboardBody(
    # Body content
    fluidRow(
      column(
        width = 6,
        box(
          title = "Small Panel",
          width = NULL,
          status = "info",
          solidHeader = TRUE,
          collapsible = TRUE,
          p("https://www.kaggle.com"),
          p("https://stackoverflow.com"),
        )
      )
    )
  )
)

server <- function(input, output) {
  # Server logic
}

shinyApp(ui, server)
Shiny applications not supported in static R Markdown documents